#!/usr/bin/bash
src_snap="/home/images/$1.qcow2"
dest_snap="/home/images/$2.qcow2"
snap()
{
        qemu-img create -f qcow2 -b $src_snap $dest_snap &>/dev/null &
}
virt()
{
        virt-install \
        --name $1 \
        --vcpus 2 \
        --memory 2048 \
        --disk $dest_snap,bus=virtio \
        --network bridge=br0,model=virtio \
        --import &>/dev/null &
}

if [ -f $src_snap ];then
	if [ -f $dest_snap ];then
		echo "快照文件已存在"
	else
		snap
		virt $2
	fi
else
	echo "没有快照文件"
fi
